const loadingPlugin = {
    install(Vue, options) {
      Vue.prototype.$startLoading = function (id) {
        let loadingId = 'loadingObj'
        if(id){
          loadingId += id
        }
        window[loadingId] = this.$loading({
            lock: true,
            text: 'Loading',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          });
      }

      Vue.prototype.load = Vue.prototype.$startLoading;

      Vue.prototype.$closeLoading = function () {
        window.loadingObj.close();
      }

      Vue.prototype.getDpi = function() {
        for (var i = 56; i < 2000; i++) {
            if (matchMedia("(max-resolution: " + i + "dpi)").matches === true) {
                return i;
            }
        }
    }


    }
  }

  export default loadingPlugin;
